package com.cci.kangdao.dao;


import com.cci.kangdao.dao.model.CustomerAmtRel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface CustomerAmtRelMapper {
    int deleteByPrimaryKey(Long ID);

    int insert(CustomerAmtRel record);

    int insertSelective(CustomerAmtRel record);

    CustomerAmtRel selectByPrimaryKey(Long ID);

    int updateByPrimaryKeySelective(CustomerAmtRel record);

    int updateByPrimaryKey(CustomerAmtRel record);

    int getRelationByUserIdAndAmt(@Param("userId") Long userId, @Param("amt") String amt);

    CustomerAmtRel getProRelationByUserIdAndAmt(@Param("userId") Long userId, @Param("amt") String amt);

    void addCustomerEngineRel(Map<String, Object> map);

    int updateDeleteByCustomerEngineRelId(CustomerAmtRel customerAmtRel);

    @Select("select count(*) from CustomerAmtRel_T amt left join CustomerEngineRel_T en on amt.CustomerEngineRelId= en.ID \n" +
            "where amt.ID= #{id} and amt.Flag=0 and en.Flag=0 and en.ESN=#{esn}")
    int getCountByCustomerAmtIdAndEsn(@Param("id") Long id, @Param("esn") String esn);

    @Select("select count(*) from CustomerAmtRel_T amt left join CustomerEngineRel_T en on amt.CustomerEngineRelId= en.ID \n" +
            "where en.ID= #{id} and amt.Flag=0 and en.Flag=0 and amt.AmtNo=#{amt}")
    int getCountByCustomerEngineIdAndEsn(@Param("id") Long id, @Param("amt") String amt);
}